function drawSelectRect(event){
	selectLayer.graphics.clear();
	selectLayer.graphics.drawRect(2,"#000000",[mouseObject.x,mouseObject.y,event.selfX-mouseObject.x,event.selfY-mouseObject.y],true,"#CCCCCC");
}
function queryRandTarget(chara){
	var query = (chara.belong == BELONG.ENEMY)?selfQuery:enemyQuery;
	var w = (LGlobal.width - atkMap.mapX)*0.125;
	var h = LGlobal.height*0.125;
	var qArr,qArray=[[0,0],[0,-1],[1,0],[0,1],[-1,0],[1,-1],[1,1],[-1,1],[-1,-1]],
	cx = chara.x/w >>> 0,
	cy = chara.y/h >>> 0,
	x,y,target=null;
	for(var i=0;i<qArray.length;i++){
		qArr = qArray[i];
		x = (cx + qArr[0])*w;
		y = (cy + qArr[1])*h;
		arr_query = query.getDataInRect(new LRectangle(x,y,w,h));
		if(arr_query.length){
			target = queryTargets(chara,arr_query);
			break;
		}
	}
	if(target == null){
		return queryRandFromAll(chara);
	}
	return target;
}
function queryRandFromAll(chara){
	var list = (chara.belong == BELONG.SELF)?enemyList:selfList;
	return list[list.length*Math.random() >>> 0];
}
function queryTargets(chara,arr_query){
	if(!arr_query || arr_query.length == 0)return null;
	if(chara.target){
		for(var i=0;i<arr_query.length;i++){
			if(arr_query[i].objectindex == chara.target.objectindex)return chara.target;
		}
	}
	return arr_query[arr_query.length*Math.random() >>> 0];
}
function checkCanAttack(chara){
	return (chara.target && chara.target.hp > 0 && Math.abs(chara.x - chara.target.x) <= 40 && Math.abs(chara.y - chara.target.y) <= 40)
}